<%--
  Created by IntelliJ IDEA.
  User: New
  Date: 2021/5/11
  Time: 11:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="model.Product" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
   String itemName=  request.getParameter("itemName");
   Integer quantity=Integer.parseInt(request.getParameter("quantity"));

   Product product = new Product();
   product.setItemName(itemName);
   product.setQuantity(quantity);

    List<Product> list = (List<Product>) session.getAttribute("list");

    if(list==null){
        list = new ArrayList<>();
    }

    list.add(product);

    session.setAttribute("list",list);

    response.sendRedirect("../../view/cart/list.jsp");

%>
</body>
</html>
